﻿@{
    ViewBag.Title = "Form";
    Layout = "~/Views/Shared/_Uploader.cshtml";
}
@section Content {
    <script>

        var keyValue = $.request("formid");
        var type = $.request("type");
        var SiteName = $.request("SiteName");

        $(function () {
            $.ajax({
                url: "/OrderFlowManage/ClientOrder/GetToken",
                data: {},
                dataType: "json",
                async: false,
                success: function (data) {
                    $("#token").val(data.token);
                }
            });
            if (type == "PDF") {
                document.getElementById("userfile").accept = "application/pdf";
            }
            //else if (type == "PPT") {
            //    document.getElementById("userfile").accept = ".ppt,.pptx";
            //}
            if (SiteName != "") {
                $("#userfilename").val("uploads/files/path/" + unescape(SiteName)+"/");
            }
        });

        function submitForm() {
            var filePath = $("#userfilepath").val();
            if (keyValue.length > 12)
                keyValue = "iframe" + keyValue;
            top.frames[keyValue].getPath(filePath, type);
            $.modalClose();
        }
    </script>
}

<div style="padding-top: 20px; margin-right: 20px;">
    <div class="container">
        <!-- Document：https://developer.qiniu.com/kodo/manual/form-upload -->
        <form id="testform" method="post" enctype="multipart/form-data">
            <input name="key" id="key" type="hidden" value="">
            <input id="token" name="token" type="hidden" value="">
            <input id="userfile" class="form-control" name="file" type="file" accept=".ppt,.pptx" />
            <input id="userfilepath" name="userfilepath" type="hidden" />
            <input id="userfilename" name="userfilename" value="" type="hidden" />

            <!-- take photo with phone -->
            <!-- <input id="userfile" name="file" accept="image/*" type="file" /> -->
            <!-- take video with phone -->
            <!-- <input id="userfile" name="file" type="file" accept="video/*"/> -->

            <input name="accept" type="hidden" />
        </form>

        <!-- add file -->
        <label for="userfile">
            <span></span>
            <em>添加文件</em>
        </label>

        <!-- upload info -->
        <div class="selected-file"></div>
        <div class="progress"></div>
        <div class="uploaded-result"></div>
    </div>
</div>


